package cc.wsyw126.java.stream;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * Created by junpeng.yang on 16/8/24.
 */
public class JavaReduce {
    public static void main(String[] args) {
        String concat = Stream.of("a", "B", "c", "D", "e", "F").
                filter(x -> x.compareTo("z") > 0).
                reduce("", String::concat);
        System.out.println(concat == "");
        System.out.println("concat = " + concat);
        System.out.println("----");
        Optional<String> Oconcat =  Stream.of("a", "B", "c", "D", "e", "F").
                filter(x -> x.compareTo("Z") > 0).
                reduce(String::concat);
        System.out.println("Oconcat = " + Oconcat.orElse(null));
    }
}
